<template>
  <div class="dashboard-editor-container">
    <!-- <github-corner class="github-corner" /> -->

    <panel-group @handleSetLineChartData="handleSetLineChartData" />
    <div class="sys-info-main">
     <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
        <el-card shadow="never">
          <div slot="header">
            <svg-icon icon-class="peoples" />
            <span class="margin-left-xs">项目发起人</span>
          </div>
          <div v-for="(item, index) in teamList" :key="index" class="team-flex">
            <a
              target="_blank"
              :href="item.link"
            >
              <span>{{ item.username }}</span>
            </a>
            <!-- <el-alert
              :description="item.description"
              :title="item.username"
              :type="item.type"
              :closable="item.closable"
            /> -->
          </div>
          <br>
        </el-card>
        <el-card class="card margin-top-sm" shadow="never">
          <div slot="header">
            <svg-icon icon-class="tree-table" />
            <span class="margin-left-xs">依赖信息</span>
            <div style="float: right">部署时间:{{ updateTime }}</div>
          </div>
          <div class="sys-tree">

            <div class="bottom-btn">
                <el-popover placement="top" width="250" trigger="hover">
                  <p class="text-center">
                    欢迎添加微信咨询：
                    <el-image src="https://www.hopesfire.com/data/attachment/album/202202/11/175420g200020zx0dg45b2.jpg.thumb.jpg" />
                  </p>
                  <a slot="reference" href="https://jq.qq.com/?_wv=1027&k=JwqVuQjw" target="_blank">
                    <el-button type="primary">客服微信</el-button>
                  </a>
                </el-popover>
                <a
                  target="_blank"
                  href="https://github.com/tuhuokeji/diandicms"
                >
                  <el-button type="warning">github下载源码点star</el-button>
                </a>
                <a
                  target="_blank"
                  href="https://gitee.com/tuhuokeji/diandcms"
                >
                  <el-button type="warning">码云下载源码点star</el-button>
                </a>
                <a
                  target="_blank"
                  href="https://www.dandicloud.com/"
                >
                  <el-button type="danger">店滴云官网</el-button>
                </a>
                <!--  <el-popover placement="top" width="250" trigger="hover">
                  <p>谢谢您愿意支持开源，加群获取文档，群内提供基础模板</p>
                  <el-image :src="require('@/assets/ewm.png')"></el-image>
                  <a slot="reference" target="_blank">
                    <el-button type="warning">文档</el-button>
                  </a>
                </el-popover> -->
            </div>
          <table class="table">
            <tr>
              <td>@vue/cli版本</td>
              <td>{{ devDependencies['@vue/cli-service'] }}</td>
              <td>vue版本</td>
              <td>{{ dependencies['vue'] }}</td>
            </tr>
            <tr>
              <td>vuex版本</td>
              <td>{{ dependencies['vuex'] }}</td>
              <td>vue-router版本</td>
              <td>{{ dependencies['vue-router'] }}</td>
            </tr>
            <tr>
              <td>element-ui版本</td>
              <td>{{ dependencies['element-ui'] }}</td>
              <td>axios版本</td>
              <td>{{ dependencies['axios'] }}</td>
            </tr>
            <tr>
              <td>eslint版本</td>
              <td>{{ devDependencies['eslint'] }}</td>
              <td>webpack版本</td>
              <td>{{ devDependencies['webpack'] }}</td>
            </tr>
            <tr>
              <td>sass版本</td>
              <td>{{ devDependencies['sass'] }}</td>
              <td>mockjs版本</td>
              <td>{{ devDependencies['mockjs'] }}</td>
            </tr>

            <!-- <tr>
              <td>diandi-admin版本</td>
              <td>{{ dependencies['diandi-admin'] }}</td>
              <td>diandi-ele-form版本</td>
              <td>{{ dependencies['diandi-ele-form'] }}</td>
            </tr><tr>
              <td>diandi-ele-form-bmap版本</td>
              <td>{{ dependencies['diandi-ele-form-bmap'] }}</td>
              <td>diandi-ele-form-dynamic版本</td>
              <td>{{ dependencies['diandi-ele-form-dynamic'] }}</td>
            </tr><tr>
              <td>diandi-ele-form-filter版本</td>
              <td>{{ dependencies['diandi-ele-form-filter'] }}</td>
              <td>diandi-ele-form-image-uploader版本</td>
              <td>{{ dependencies['diandi-ele-form-image-uploader'] }}</td>
            </tr><tr>
              <td>diandi-ele-form-tree-select版本</td>
              <td>{{ dependencies['diandi-ele-form-tree-select'] }}</td>
              <td>diandi-ele-form-upload-file版本</td>
              <td>{{ dependencies['diandi-ele-form-upload-file'] }}</td>
            </tr><tr>
              <td>diandi-ele-form-video-uploader版本</td>
              <td>{{ dependencies['diandi-ele-form-video-uploader'] }}</td>
              <td>diandi-ele-upload-file版本</td>
              <td>{{ dependencies['diandi-ele-upload-file'] }}</td>
            </tr><tr>
              <td>diandi-ele-upload-image版本</td>
              <td>{{ dependencies['diandi-ele-upload-image'] }}</td>
              <td>diandi-ele-upload-video版本</td>
              <td>{{ dependencies['diandi-ele-upload-video'] }}</td>

            </tr> -->
          </table>
          </div>

        </el-card>

      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
        <version-information :dependencies="dependencies" :dev-dependencies="devDependencies" />

      </el-col>

    </el-row>
    <el-row :gutter="20" class="margin-top-sm">
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
        <plan />

      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
        <el-card class="card" shadow="never">
          <div slot="header">
            <svg-icon icon-class="form" />
            <span class="margin-left-xs">更新日志</span>
          </div>
          <div class="update-log">
            <el-timeline :reverse="reverse">
              <el-timeline-item
                v-for="(activity, index) in activities"
                :key="index"
                :timestamp="activity.timestamp"
                :color="activity.color"
              >
                {{ activity.content }}
              </el-timeline-item>
            </el-timeline>
          </div>

        </el-card>

      </el-col>
    </el-row>
    </div>
    <!-- <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>

    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <raddar-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart />
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <bar-chart />
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="8">
      <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 12}" :xl="{span: 12}" style="padding-right:8px;margin-bottom:30px;">
        <transaction-table />
      </el-col>
      <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
        <todo-list />
      </el-col>
      <el-col :xs="{span: 24}" :sm="{span: 12}" :md="{span: 12}" :lg="{span: 6}" :xl="{span: 6}" style="margin-bottom:30px;">
        <box-card />
      </el-col>
    </el-row> -->
  </div>
</template>

<script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
import RaddarChart from './components/RaddarChart'
import PieChart from './components/PieChart'
import BarChart from './components/BarChart'
import TransactionTable from './components/TransactionTable'
import TodoList from './components/TodoList'
import BoxCard from './components/BoxCard'
import Plan from './components/Plan.vue'
import VersionInformation from './components/VersionInformation.vue'

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'BlocDashboard',
  components: {
    Plan,
    VersionInformation,
    GithubCorner,
    PanelGroup,
    LineChart,
    RaddarChart,
    PieChart,
    BarChart,
    TransactionTable,
    TodoList,
    BoxCard
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      timer: 0,
      updateTime: '2022-02-11',
      nodeEnv: process.env.NODE_ENV,
      dependencies: {},
      devDependencies: {},
      // 更新日志
      reverse: true,
      activities: [],
      cmsTitle: "\n\t店滴CMS,快速构建多商户业务模型\n\t<a href='https://www.hopesfire.com/' target='_blank'>官方社区</a>",
      teamList: [
        {
          'username': '王春生',
          'link': 'https://www.hopesfire.com/home.php?mod=space&uid=1&do=profile&from=space'
        },
        {
          'username': '姚佳文',
          'link': 'https://www.hopesfire.com/home.php?mod=space&uid=242&do=profile&from=space'
        }
      ]
    }
  },
  created() {
    console.log('devDependencies', this.$devDependencies)
    this.devDependencies = this.$devDependencies
    this.dependencies = this.$dependencies
    this.fetchData()
  },
  beforeDestroy() {
    clearInterval(this.timer)
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    },
     handleClick(e) {
      this.$baseMessage(`点击了${e.name},这里可以写跳转`)
    },
    handleZrClick(e) {},
    handleChangeTheme() {
      this.$baseEventBus.$emit('theme')
    },
    async fetchData() {
      const data = [
        {
          'content': '店滴开源框架项目立项',
          'timestamp': '2021-05-01'
        },
        {
          'content': '店滴单商户功能上线',
          'timestamp': '2021-07-01'
        },
        {
          'content': '店滴多商户功能上线',
          'timestamp': '2021-10-01'
        },
        {
          'content': '店滴稳定版发布',
          'timestamp': '2021-11-01'
        },
        {
          'content': '店滴商业版上线',
          'timestamp': '2021-12-01'
        },
        {
          'content': '店滴中后台稳定版上线',
          'timestamp': '2022-02-01'
        },
        {
          'content': '确定以音视频处理为核心技术的发展方向',
          'timestamp': '2022-02-07'
        }
      ]
      data.map((item, index) => {
        if (index === data.length - 1) {
          item.color = '#0bbd87'
        }
      })
      this.activities = data
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 15px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}

 .sys-info-main {
    padding: 0 !important;
    margin: 0 !important;
    background: #f5f7f8 !important;
    .sys-tree {
        height: 270px;
    }
    ::v-deep {
      .el-alert {
        padding: 20px;

        &--info.is-light {
          min-height: 82px;
          padding: 20px;
          margin-bottom: 15px;
          color: #909399;
          background-color: #fff;
          border: 1px solid #ebeef5;
        }
      }

      .el-card__body {
        .echarts {
          width: 100%;
          height: 115px;
        }
      }
    }

    .card {
      ::v-deep {
        .el-card__body {
          .echarts {
            width: 100%;
            height: 305px;
          }
        }
      }
    }

    .bottom {
      padding-top: 20px;
      margin-top: 5px;
      color: #595959;
      text-align: left;
      border-top: 1px solid #595959;
    }

    .table {
      width: 100%;
      color: #666;
      border-collapse: collapse;
      background-color: #fff;

      td {
        position: relative;
        min-height: 20px;
        padding: 9px 15px;
        font-size: 14px;
        line-height: 20px;
        border: 1px solid #e6e6e6;

        &:nth-child(odd) {
          width: 20%;
          text-align: right;
          background-color: #f7f7f7;
        }
      }
    }

    .icon-panel {
      height: 117px;
      text-align: center;
      cursor: pointer;

      svg {
        font-size: 40px;
      }

      p {
        margin-top: 10px;
      }
    }
    .update-log {
      padding-top: 15px;
        height: 386px;
        overflow: auto;
    }
    .team-flex{
      display: inline;
      font-size: 14px;
      span{
        padding-right: 5px;
        color: #1890ff;
      }
    }
    .bottom-btn {
      button {
        margin: 5px 10px 15px 0;
      }
    }
  }
</style>
